//
//  SendFoodViewController.swift
//  SmartHousekeeper
//
//  Created by 张磊 on 2020/2/20.
//  Copyright © 2020 LS. All rights reserved.
//

import UIKit
import SnapKit

public let dataArr = ["水果", "蔬菜", "河海鲜", "肉禽", "调料", "粮油", "肥肥", "开开"]
public let dataArr1 = [FreshFoodSecondLevelCellModel(imageName: "cucumber", foodName: "本地黄瓜", foodArea: "锦州黑山胖子家后院", foodUnit: "500g", foodPrice: "5.5"),FreshFoodSecondLevelCellModel(imageName: "Tomatoes", foodName: "胡萝卜", foodArea: "锦州黑山开开家前门楼子", foodUnit: "500g", foodPrice: "5.5")]

class SendFoodViewController: UIViewController {

    let naviRightItem = UIButton(normalImage: ImageName("IOS_navi_more"))
    lazy var topView = FreshFoodTopView()
    lazy var bottomView = FreshFoodBottomView()
    lazy var bodyView = FreshFoodBodyView()
    lazy var segmentBar = LWSegmentBar()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        

        self.view.backgroundColor = UIColor.white
        self.navigationController?.navigationBar.isTranslucent = false
        initWithControl()
        initWithSubscribeSignal()
        
        segmentBar.titles = dataArr
        segmentBar.selectIndex = 1
        bodyView.firstLevelData = dataArr.shuffled()
        bodyView.secondLevelData = dataArr1 + dataArr1 + dataArr1 + dataArr1

    }
    
    func initWithControl() {
        self.view.addSubviews([naviRightItem, topView, bottomView, segmentBar, bodyView])
        naviRightItem.snp.makeConstraints { (make) in
            make.left.top.equalToSuperview()
            make.height.width.equalTo(Adapter(24))
        }
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: naviRightItem)
        topView.snp.makeConstraints { (make) in
            make.left.right.width.top.equalToSuperview()
            make.height.equalTo(Adapter(66))
        }
        
        bottomView.snp.makeConstraints { (make) in
            make.left.width.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(KSafeAreaBottom())
            make.height.equalTo(Adapter(88) + KSafeAreaBottom())
        }
        segmentBar.snp.makeConstraints { (make) in
            make.left.width.right.equalToSuperview()
            make.height.equalTo(Adapter(54))
            make.top.equalTo(topView.snp.bottom).offset(Adapter(5))
        }
        bodyView.snp.makeConstraints { (make) in
            make.left.width.right.equalToSuperview()
            make.top.equalTo(segmentBar.snp.bottom)
            make.bottom.equalTo(bottomView.snp.top)
        }
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.view.endEditing(true)
    }
}
